package com.atguigu.exam.exception;

import com.atguigu.exam.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    //处理异常的方法
    @ExceptionHandler(value = Exception.class)
    public Result doResolveException(Exception e){
        log.error("系统异常!异常信息为: {}",e.getMessage());
        //返回对应的提示
        return Result.error(e.getMessage());
    }
}
